package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {
    //根据分类id查询品牌集合
    @Select("SELECT b.id, b.name, b.letter, b.image from tb_brand b \n" +
            "LEFT JOIN tb_category_brand cb on cb.brand_id = b.id\n" +
            "LEFT JOIN tb_category c on c.id = cb.category_id\n" +
            "where c.id =#{cid}  ")
    List<Brand> queryBrandsByCategoryId(@Param("cid") Long cid);
}
